import request from '../utils/request'


export interface CateListModel {
    data: categoryDataModel;
}
export interface anyObjModel {
    [props:string]:any
}
export interface categoryDataModel {
    categoryGroupList: categoryValueModel[];
    categoryL1List: categoryModel[];
    categoryL2List: categoryModel[];
    currentCategory: categoryModel[];
    categoryItems?:anyObjModel;
    categoryL1?: categoryModel[]
    itemList: anyObjModel[]
}

export interface categoryValueModel {
    
    categoryList: categoryModel[];
    id: string;
    name: string;
}
export interface categoryModel {

    bannerList: bannerModel[];
    bannerUrl: string;
    categoryType: string;
    extra: extraModel;
    frontDesc: string;
    frontName: string;
    frontNameIcon: string;
    iconUrl: string;
    id: string;
    imgUrl: string;
    level: string;
    name: string;
    showIndex: number;
    subCateList: [];
    superCategoryId: string;
    type: number;
    wapBannerUrl: string;
    wapExpandPicTargetUrl: string;
}
export interface bannerModel {
    extra: extraModel;
    id: string;
    picUrl: string;
    targetUrl: string;
}
export interface extraModel {
    crmUserGroupId: string;
    crmUserGroupName: string;
    itemFrom: number;
    materialContentFrom: number;
    materialId: string;
    materialName: string;
    materialType: string;
    rcmdSort: boolean;
    resourcesId: number;
    taskId: string;
    taskType: number;
}



export default {
    // 导航栏渲染
    getCategoryList() {
        return request.get<any, CateListModel>(`/dapi/item/cateList.json?__timestamp=1630131286110&categoryId=`)
    },
    // 根据分类ID获取分类的列表
    getCategoryByIdList(id: string) {
        return request.get<any, CateListModel>(`/dapi/item/cateList.json?__timestamp=1630131455012&categoryId=${id}`)
    },
    // 获取某个分类下的商品列表
    getCategoryDataList(categoryType: string, id: string, superCategoryId: string) {
        // console.log(categoryType);
        // console.log(superCategoryId);
        // console.log(id);

        return request.get<any, CateListModel>(`/dapi/item/list.json?token=fb961927ac33db422087839e2ceb5012&categoryType=${categoryType}&subCategoryId=${id}&categoryId=${superCategoryId}`)
    },
    // 获取商品详情
    // /item/detail.json?__timestamp=1681296432988&id=4069098
    getGoodsDetail(id:string){
        return request.get<any,anyObjModel>(`/dapi/item/detail.json?id=${id}`)
    }
}



